﻿using System;
using System.Windows;
using System.Windows.Data;

namespace XmlStudio.Converters {
    /// <summary>
    /// Converts <see cref="bool"/> to <see cref="Visibility"/>. If true, returns Collapsed, otherwise Visible.
    /// </summary>
    public class BoolToVisibilityNegativeConverter : IValueConverter {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            if(value is bool) {
                var val = (bool)value;
                if(val) {
                    return Visibility.Collapsed;
                }

                return Visibility.Visible;
            }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            return null;
        }
    }
}